Subj. Do you plain make it open source, or it always by proprietary?
Terra Informatica Forums » tiscript
How get linux(freebsd) build of tscript????
(24 posts)-
Posted 1 year ago #
-
I am not sure I understand what do you mean.
TIScript is open source (BSD license). It's source code is here:
http://code.google.com/p/tiscript/I didn't do linux builds recently so I have no fresh GNU make compatible files in-place at the moment.
Posted 1 year ago # -
I don't find any link to sources at this site, so i ask this question. Thank you.
Posted 1 year ago # -
Is will by any problem, if wchar_t type was 4 bytes long, like on FreeBSD or Linux??
I have next Warning:
tl_slice.h: In instantiation of 'tool::charset<wchar_t, 45, 93>':
tl_slice.h:445: instantiated from 'int tool::match(tool::slice<T>, const CT*) [with CT = wchar_t]'
tl_slice.h:499: instantiated from here
tl_slice.h:387: warning: left shift count >= width of typeand this like make it:
enum { SET_SIZE = (1 << (sizeof(CT) * 8)) };and if i replace it by :
enum { SET_SIZE = (1 << 16)};
Is it all ok??
Posted 1 year ago # -
Yeah, tl_slice.h needs to be fixed. But in any case you should compile with "-fshort-wchar" option. By ECMA spec strings in JS are UCS-2 sequences (Basic Multi Plane subset of Unicode).
In tiscript internal representation of strings is UTF-16 and in fact it should be enough to define
typedef unsigned short wchar;for the __GNUC__ section intl_config.hfile. I'll check.Posted 1 year ago # -
I don't think that use of -fshort-wchar option is acceptable in this case because tscript use functions like wcscpy from stdlib, which desire that wchar_t will by 4 bytes long, if no in best way we get segfault error
Posted 1 year ago # -
I'll do gcc build in a day or two.
Posted 1 year ago # -
Ok waiting:-)) But now i have compile and build tscript on FreeBSD7.2 but with little changes of source code, and on simple test its work
Posted 1 year ago # -
What kind of changes you've made?
Posted 1 year ago # -
here is my patch file for revision 44 of svn:
Index: int/cs_api.cpp =================================================================== --- int/cs_api.cpp (revision 44) +++ int/cs_api.cpp (working copy) @@ -1,6 +1,10 @@ #include "tiscript.h" #include "cs.h" +#ifndef WINDOWS +#include "tl_string.h" +#include <dlfcn.h> +#endif struct xstream: public tis::stream { @@ -627,9 +631,30 @@ return true; } else + { + FreeLibrary(hmod); return false; + }; #else -#error "Implement dl_load!" + if(!filename.like(L"*.so") ) + { + fullpath = tool::ustring::format(L"%s.so",filename.start); + filename = fullpath; + }; + void* hmod = dlopen(tool::string(filename.start), RTLD_LAZY); + if(!hmod) return false; + TIScriptLibraryInitFunc* pentry = (TIScriptLibraryInitFunc*)dlsym(hmod,"TIScriptLibraryInit"); + if(pentry) + { + pentry((tiscript_VM *)c,&native_interface); + return true; + } + else + { + dlclose(hmod); + return false; + }; +//#error "Implement dl_load!" #endif } } Index: libtiscript.cpp =================================================================== --- libtiscript.cpp (revision 0) +++ libtiscript.cpp (revision 0) @@ -0,0 +1,8 @@ +#include <tiscript.h> + +extern tiscript_native_interface native_interface; + +tiscript_native_interface* TIScriptAPI() +{ + return &native_interface; +}; Index: main.cpp =================================================================== --- main.cpp (revision 44) +++ main.cpp (working copy) @@ -37,6 +37,7 @@ struct console_stream: public tis::stream { virtual int get() { int c = getchar(); return c != EOF? to_wchar(c) : int(EOS); } + virtual bool is_output_stream() const { return true; } virtual bool put(int ch) { char bf[MB_LEN_MAX]; @@ -108,7 +109,7 @@ { switch (argv[i][1]) { - case '?': + case 'h': Usage(); break; case 'c': /* compile source file */ @@ -332,13 +333,13 @@ s[erver] - server script - interprets <% %>n script inclusions, n b[ytecode] - load as compiled bytecode file.n - [-?] display (this) help informationn + [-h] display (this) help informationn [file] load a source or bytecode file, n supported file extensions: n js - client script (ECMAScript),n jsp - server script (ECMAScript),n jsb - compiled script (bytecodes).nn -See: http://terrainformatica.com/tiscript for more details." +See: http://terrainformatica.com/tiscript for more details.nn" ); exit(1); Index: sdk/bin/tiscript.dll =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: sdk/include/tiscript-streams.hpp =================================================================== --- sdk/include/tiscript-streams.hpp (revision 44) +++ sdk/include/tiscript-streams.hpp (working copy) @@ -70,7 +70,13 @@ FILE* _file; std::wstring _name; public: - file_istream(const wchar_t* filename) { _file = _wfopen(filename,L"rb"); _name = filename; } + file_istream(const wchar_t* filename) + { + char fn[1024]; + wcstombs ( fn, filename, 1024 ); + _file = fopen( fn , "rb"); + _name = filename; + } virtual void close() { if(_file) {fclose(_file);_file = 0;} } virtual const wchar_t* stream_name() { return _name.c_str(); } @@ -109,4 +115,4 @@ } -#endif No newline at end of file +#endif Index: sdk/include/tiscript.hpp =================================================================== --- sdk/include/tiscript.hpp (revision 44) +++ sdk/include/tiscript.hpp (working copy) @@ -224,7 +224,7 @@ wchar buffer[512]; public: error( int param_n, const wchar* expecting_type ) - { swprintf(buffer, L"parameter %d, expecting %s", param_n-2, expecting_type); } + { swprintf(buffer, 512, L"parameter %d, expecting %s", param_n-2, expecting_type); } const wchar* msg() { return buffer; } }; Index: sdk/lib/tiscript.lib =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: tool/tl_config.h =================================================================== --- tool/tl_config.h (revision 44) +++ tool/tl_config.h (working copy) @@ -85,8 +85,9 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> - #include <X11/keysym.h> - #include "vk_codes.h" + #include <wchar.h> + //#include <X11/keysym.h> + //#include "vk_codes.h" #define stricmp strcasecmp Index: tool/tl_slice.h =================================================================== --- tool/tl_slice.h (revision 44) +++ tool/tl_slice.h (working copy) @@ -384,7 +384,7 @@ { //enum { SET_SIZE = (1 << (min(sizeof(CT),2) * 8)) }; - enum { SET_SIZE = (1 << (sizeof(CT) * 8)) }; + enum { SET_SIZE = ((size_t)1 << (sizeof(CT) * 8)) }; unsigned char codes[ SET_SIZE >> 3 ]; Index: tool/tl_tokenizer.cpp =================================================================== --- tool/tl_tokenizer.cpp (revision 44) +++ tool/tl_tokenizer.cpp (working copy) @@ -9,7 +9,6 @@ #include "tl_tokenizer.h" #include "tl_ustring.h" -#include "tl_value.h" #include "tl_streams.h" #ifdef _DEBUG @@ -821,10 +820,12 @@ wchars t = s.get_value(); int dp = t.index_of('$'); if( dp < 0 ) return value(); - int64 dollars = to_int64( wchars( t.start, dp ) ); + wchars wchar_dollars = wchars( t.start, dp ); + int64 dollars = to_int64(wchar_dollars); t.prune(dp + 1); if(t.length > 4) t.length = 4; - int cents = to_uint( wchars(t)); + wchars wchar_cents = wchars(t); + int cents = to_uint(wchar_cents); switch( t.length ) { case 1: cents *= 1000; break; Index: tool/tl_tokenizer.h =================================================================== --- tool/tl_tokenizer.h (revision 44) +++ tool/tl_tokenizer.h (working copy) @@ -19,6 +19,7 @@ #include "tl_string.h" #include "tl_ustring.h" #include "tl_hash_table.h" +#include "tl_value.h" namespace tool {Posted 1 year ago # -
But here is a big problem with this code:
template <typename CT, CT sep = '-', CT end = ']' > struct charset { //enum { SET_SIZE = (1 << (min(sizeof(CT),2) * 8)) }; enum { SET_SIZE = ((size_t)1 << (sizeof(CT) * 8)) }; unsigned char codes[ SET_SIZE >> 3 ];if extend SET_SIZE to int64(because wchar_t on FreeBSD 4 bytes) type than codes will have 512MB of RAM and need other algorithm of detect that symbol present in range, or just simply truncate symbols range to 2^16 (in this case codes will by 8kb long not bad for on stack allocation)
In my build "String.match" method doesn't work, because i don't modify this place
Posted 1 year ago # -
I've updated googlecode with v 4.0.1.0 of the tiscript. That issue is fixed there as far as I can tell.
tantra, terribly sorry but could you recreate your patch again so I can apply it on top of rev.45?
Posted 1 year ago # -
>>>That issue is fixed there as far as I can tell.
If you mean that i must use -fshort-wchar?? This use is wrong because in your code you use crt functions like wcstol, wtof, wcslen and so on, and result of they work will by improper, for example if i compile this sample with -fshort-wchar
#include <wchar.h> #include <stdio.h> int main(int argc, char* argv[] ) { printf("%unn", wcslen(L"ret")); return 0; };this program will print 33, but not 3.
If i define only wchar type like "typdef unsigned short wchar", i got compile time error of type cast like this:
freebsd# g++ -c -I"../include" -I"../tool" snscanf.cpp In file included from tl_array.h:14, from snscanf.cpp:11: tl_basic.h: In function 'int tool::wtoi(const wchar*, int)': tl_basic.h:546: error: cannot convert 'const wchar*' to 'const wchar_t*' for argument '1' to 'long int wcstol(const wchar_t*, wchar_t**, int)'So problem with this code doen't disappear:
template <typename CT, CT sep = '-', CT end = ']' >
struct charset
{
enum { SET_SIZE = (1 << (sizeof(CT) * 8)) };unsigned char codes[ SET_SIZE >> 3 ];
But you write:
>>>>In tiscript internal representation of strings is UTF-16So if i simply replace "enum { SET_SIZE = (1 << (sizeof(CT) * 8)) };" replace with enum { SET_SIZE = 16 };" Is all ok???
And patch i will make for 1 day.
Posted 1 year ago # -
Change it to this:
enum { SET_SIZE = (1 << ( min(2,sizeof(CT)) * 8)) };And
-fshort-wcharis *not* needed.Posted 1 year ago # -
I try it on freebsd(gcc version 4.2.1 20070719 [FreeBSD]) this wonn't compile with follow error:
freebsd# g++ -c -DNDEBUG -O3 -I"../include" -I"../tool" tl_base64.cpp In file included from tl_array.h:15, from tl_string.h:21, from tl_base64.h:11, from tl_base64.cpp:10: tl_slice.h:386: error: 'min(T1, T2)' cannot appear in a constant-expression tl_slice.h:386: error: a function call cannot appear in a constant-expressionPosted 1 year ago # -
Define it as:
enum { SET_SIZE = ( 1 << ((sizeof(CT) > 2 ? 2 : sizeof(CT)) * 8) ) };
then. GCC should be able to handle this.Posted 1 year ago # -
'
slice chop( const slice& delimeter, slice& head ) const
{
int d = index_of( s );
if( d < 0 ) { head = *this; return slice(); }
head = slice(start,d);
return slice(start + d + s.length, length - d - s.length);
}
bool split( const slice& delimeter, slice& head, slice& tail ) const
{
int d = index_of( s );
if( d < 0 ) return false;
head = slice(start,d);
tail = slice(start + d + s.length, length - d - s.length);
return true;
}
'Invalid have following error:
In file included from tl_array.h:15,
from tl_string.h:21,
from tl_base64.h:11,
from tl_base64.cpp:10:
tl_slice.h: In member function 'tool::slice<T> tool::slice<T>::chop(const tool::slice<T>&, tool::slice<T>&) const':
tl_slice.h:183: error: 's' was not declared in this scope
tl_slice.h: In member function 'bool tool::slice<T>::split(const tool::slice<T>&, tool::slice<T>&, tool::slice<T>&) const':
tl_slice.h:190: error: 's' was not declared in this scopeBut i found that they never have any link to they. So if i remove them is it all ok??
And what in tool dir do this unreferensed files:
ce_time.c
ce_tool.c?
Posted 1 year ago # -
Fixed in rev #46 on googlecode.
ce_time.candce_tool.care used in WinCE builds (Windows Mobile) - functions missed on that platform.Posted 1 year ago # -
Here is my patch on rev 46
Index: int/cs_api.cpp =================================================================== --- int/cs_api.cpp (revision 46) +++ int/cs_api.cpp (working copy) @@ -1,6 +1,10 @@ #include "tiscript.h" #include "cs.h" +#ifndef WINDOWS +#include "tl_string.h" +#include <dlfcn.h> +#endif struct xstream: public tis::stream { @@ -285,7 +289,7 @@ if(cls->set_item) pd->setItem = (tis::set_item_t)cls->set_item; if(cls->finalizer) pd->destroy = (tis::destructor_t)cls->finalizer; if(cls->iterator) pd->getNextElement = (tis::get_next_element_t)cls->iterator; - if(cls->on_gc_copy) { pd->destroyParam = cls->on_gc_copy; pd->copy = &NativeObjectCopy; } + if(cls->on_gc_copy) { pd->destroyParam = (void*)cls->on_gc_copy; pd->copy = &NativeObjectCopy; } tiscript_const_def* pc = cls->consts; @@ -703,9 +707,30 @@ return true; } else + { + FreeLibrary(hmod); return false; + }; #else -#error "Implement dl_load!" + if(!filename.like(L"*.so") ) + { + fullpath = tool::ustring::format(L"%s.so",filename.start); + filename = fullpath; + }; + void* hmod = dlopen(tool::string(filename.start), RTLD_LAZY); + if(!hmod) return false; + TIScriptLibraryInitFunc* pentry = (TIScriptLibraryInitFunc*)dlsym(hmod,"TIScriptLibraryInit"); + if(pentry) + { + pentry((tiscript_VM *)c,&native_interface); + return true; + } + else + { + dlclose(hmod); + return false; + }; +//#error "Implement dl_load!" #endif } } Index: int/cs_color.cpp =================================================================== --- int/cs_color.cpp (revision 46) +++ int/cs_color.cpp (working copy) @@ -248,14 +248,21 @@ unsigned clr = color_value(obj); wchar buf[100]; buf[0] = 0; - +#ifdef WINDOWS if( !sym || sym == CsSymbolOf("RGB")) swprintf(buf,L"#%02x%02x%02x", r(clr), g(clr), b(clr) ); else if( sym == CsSymbolOf("rgb")) swprintf(buf,L"rgb(%d,%d,%d)", r(clr), g(clr), b(clr) ); else if( sym == CsSymbolOf("rgba")) swprintf(buf,L"rgb(%d,%d,%d,%f)", r(clr), g(clr), b(clr), double(255-a(clr))/255.0); - +#else + if( !sym || sym == CsSymbolOf("RGB")) + swprintf(buf,100,L"#%02x%02x%02x", r(clr), g(clr), b(clr) ); + else if( sym == CsSymbolOf("rgb")) + swprintf(buf,100,L"rgb(%d,%d,%d)", r(clr), g(clr), b(clr) ); + else if( sym == CsSymbolOf("rgba")) + swprintf(buf,100,L"rgb(%d,%d,%d,%f)", r(clr), g(clr), b(clr), double(255-a(clr))/255.0); +#endif return CsMakeCString(c,buf); } Index: int/cs_method.cpp =================================================================== --- int/cs_method.cpp (revision 46) +++ int/cs_method.cpp (working copy) @@ -695,7 +695,7 @@ return c->nothingValue; } -static value GeneratorNextElement(VM *c,value* index, value obj) +value GeneratorNextElement(VM *c,value* index, value obj) { assert(CsGeneratorP(obj)); if(!CsGeneratorP(obj)) Index: main.cpp =================================================================== --- main.cpp (revision 46) +++ main.cpp (working copy) @@ -37,6 +37,7 @@ struct console_stream: public tis::stream { virtual int get() { int c = getchar(); return c != EOF? to_wchar(c) : int(EOS); } + virtual bool is_output_stream() const { return true; } virtual bool put(int ch) { char bf[MB_LEN_MAX]; @@ -108,7 +109,7 @@ { switch (argv[i][1]) { - case '?': + case 'h': Usage(); break; case 'c': /* compile source file */ @@ -118,8 +119,9 @@ inputName = argv[i]; else Usage(); - CompileFile(&vm,inputName,outputName, forceType); + interactiveP = false; + CompileFile(&vm,inputName,outputName, forceType); outputName = NULL; break; case 'g': /* emit debugging information when compiling */ @@ -152,8 +154,8 @@ } } else { - LoadFile(&vm,argv[i],forceType); - interactiveP = false; + interactiveP = false; + LoadFile(&vm,argv[i],forceType); } } } @@ -297,7 +299,7 @@ if (fgets(lineBuffer,sizeof(lineBuffer),stdin)) { tool::ustring line(lineBuffer); - val = tis::CsEvalString(tis::CsCurrentScope(c),UNDEFINED_VALUE, line, line.length()); + val = tis::CsEvalString(tis::CsGlobalScope(c),NULL_VALUE, line, line.length()); if (val) { printf("Value: "); tis::CsPrint(c,val,c->standardOutput); @@ -332,13 +334,13 @@ s[erver] - server script - interprets <% %>n script inclusions, n b[ytecode] - load as compiled bytecode file.n - [-?] display (this) help informationn + [-h] display (this) help informationn [file] load a source or bytecode file, n supported file extensions: n js - client script (ECMAScript),n jsp - server script (ECMAScript),n jsb - compiled script (bytecodes).nn -See: http://terrainformatica.com/tiscript for more details." +See: http://terrainformatica.com/tiscript for more details.nn" ); exit(1); Index: tool/snscanf.h =================================================================== --- tool/snscanf.h (revision 46) +++ tool/snscanf.h (working copy) @@ -41,4 +41,4 @@ size_t do_scanf(scanf_input_stream* is, scanf_output_stream* os, const char *fmt); size_t do_w_scanf(scanf_input_stream* is, scanf_output_stream* os, const wchar_t *fmt); -#endif No newline at end of file +#endif Index: tool/tl_config.h =================================================================== --- tool/tl_config.h (revision 46) +++ tool/tl_config.h (working copy) @@ -92,8 +92,9 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> - #include <X11/keysym.h> - #include "vk_codes.h" + #include <wchar.h> + //#include <X11/keysym.h> + //#include "vk_codes.h" #define stricmp strcasecmp Index: tool/tl_markup.h =================================================================== --- tool/tl_markup.h (revision 46) +++ tool/tl_markup.h (working copy) @@ -29,7 +29,7 @@ { public: typedef CHAR_TYPE char_type; - typedef slice<typename CHAR_TYPE> token_value; + typedef slice<CHAR_TYPE> token_value; enum token_type { Index: tool/tl_slice.h =================================================================== --- tool/tl_slice.h (revision 46) +++ tool/tl_slice.h (working copy) @@ -177,7 +177,6 @@ } bool like(const T* pattern) const; - slice chop( const slice& delimeter, slice& head ) const { int d = index_of( delimeter ); @@ -401,10 +400,10 @@ enum { SET_SIZE = ( 1 << ((sizeof(CT) > 2 ? 2 : sizeof(CT)) * 8) ) }; unsigned char codes[ SET_SIZE >> 3 ]; - unsigned charcode(CT c) + unsigned charcode(CT c) { - return ( SET_SIZE - 1 ) & unsigned(c); - } + return ( SET_SIZE - 1 ) & unsigned(c); + } private: void set ( CT from, CT to, bool v ) Index: tool/tl_tokenizer.cpp =================================================================== --- tool/tl_tokenizer.cpp (revision 46) +++ tool/tl_tokenizer.cpp (working copy) @@ -9,7 +9,6 @@ #include "tl_tokenizer.h" #include "tl_ustring.h" -#include "tl_value.h" #include "tl_streams.h" #ifdef _DEBUG @@ -821,10 +820,12 @@ wchars t = s.get_value(); int dp = t.index_of('$'); if( dp < 0 ) return value(); - int64 dollars = to_int64( wchars( t.start, dp ) ); + wchars wchar_dollars = wchars( t.start, dp ); + int64 dollars = to_int64( wchar_dollars ); t.prune(dp + 1); if(t.length > 4) t.length = 4; - int cents = to_uint( wchars(t)); + wchars wchar_cents = wchars(t); + int cents = to_uint( wchar_cents ); switch( t.length ) { case 1: cents *= 1000; break; Index: tool/tl_value.h =================================================================== --- tool/tl_value.h (revision 46) +++ tool/tl_value.h (working copy) @@ -650,7 +650,7 @@ int uni_length = us.c_str() + us.length() - uniptr; if(uni_length <= 0) { - return value(i); + return value((int)i); } if( *uniptr == 'e' ) {Posted 1 year ago # -
And i build it with this options:
find ./ -name "*.o" -delete
find ./ -name "lib*.a" -deletecd tool
g++ -c -DNDEBUG -O3 -I"../include" -I"../tool" *.cpp ./ucdata/*.cpp
ar -rcs ../lib/libtool.a *.o
cd ..cd int
g++ -c -DNDEBUG -O3 -I"../include" -I"../tool" -I"../dybase/inc" -I"../sdk/include" *.cpp ../com/*.cpp ./sockio/sockio.cpp
ar -rcs ../lib/libtiscript.a *.o
cd ..cd dybase/src/
g++ -c -DNDEBUG -O3 -I"../inc" *.cpp
ar -rcs ../../lib/libdybase.a *.o
cd ../..g++ -c -DNDEBUG -O3 -I"./tool" -I"./int" -I"./include" main.cpp
g++ -o tiscript -L"./lib" main.o -ltiscript -ldybase -ltoolg++ -c -DNDEBUG -O3 -I"./sdk/include" libtiscript.cpp
g++ -o libtiscript.so -shared --export-dynamic -L"./lib" libtiscript.o -ltiscript -ldybase -ltoolPosted 1 year ago # -
Thanks tantra, published revision 47 on googlecode with your updates.
Posted 1 year ago # -
I found error in Date() class, or if we deeper tl_datetime.cpp on line 60, _time member of dt will corrupt, so if we do this tsscript we will get wrong date (date on system setted correct):
var dt = new Date(); stdout.print(dt.toString());we will get "Sun,1 Jan 1601 00:00:00 UTC"
if i comment "dt.set_frac_time(tv.tv_usec / 1000, tv.tv_usec % 1000, 0 );" all ok
Posted 1 year ago # -
In fact date_time::set_frac_time() needs to be changed to this:
inline bool date_time::set_frac_time ( int millis, int micros, int nanos ) { datetime_s d; cvt(d,_time); return set ( d.year, d.month, d.day, d.hour, d.minute, d.second, millis, micros, nanos ); }Posted 1 year ago # -
Rev #48
Posted 1 year ago #
Reply
You must log in to post.